package com.poseidon.pokers.ui.main;

import com.flyco.tablayout.listener.OnTabSelectListener;
import com.poseidon.pokers.BR;
import com.poseidon.pokers.R;
import com.poseidon.pokers.TabEntity;
import com.poseidon.pokers.databinding.ActivityMainBinding;
import com.then.architecture.BaseDelegate;
import com.then.architecture.VOCreator;

import java.util.ArrayList;

/**
 * Created by 42524 on 2018/1/26.
 */

public class MainActivityDelegate extends BaseDelegate<MainActivityVo, ActivityMainBinding> {

    @Override
    public int getRootLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected VOCreator createVo() {
        return new VOCreator(MainActivityVo.class, BR.vo);
    }


    protected int getContentMainId() {
        return viewDataBinding.flContent.getId();
    }

    @Override
    public void initWidget() {
        super.initWidget();
        initTab();
    }

    private void initTab() {
        vo.customTabEntities.set(new ArrayList<>());
        for (int i = 0; i < vo.titlesRes.length; i++) {
            String title = getStrRes(vo.titlesRes[i]);
            vo.customTabEntities.get().add(new TabEntity(title, vo.selectResId[i], vo.unSelectResId[i]));
        }
    }

    protected void setTabSelectListener(OnTabSelectListener listener) {
        vo.tabSelectListener.set(listener);
    }
}
